package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F60.2.1  账户所有人类型
 *
 * @author fangminwei
 * @date 2021/4/17
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F60_2_1_AccountTypeEnum {
    _0("0", "个人卡帐户"),
    _1("1", "个人非卡帐户"),
    _2("2", "对公非卡账户"),
    _3("3", "对公卡账户"),
    _4("4", "保留使用，具体参见《单位TOKEN业务发卡机构实施指南》/单位标记账户"),
    _5("5", "个人非银标借记账户"),
    _6("6", "个人非银标贷记账户"),
    _7("7", "个人非银标默认账户"),
    _9("9", "未知或与账户所有人类型无关"),
    _A("A", "个人银联积分账户"),
    _B("B", "保留使用，具体参见《客结业务指引》"),
    ;

    private String code;
    private String desc;

    F60_2_1_AccountTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F60_2_1_AccountTypeEnum find(String code) {
        F60_2_1_AccountTypeEnum result = Arrays.stream(F60_2_1_AccountTypeEnum.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
